
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>支付 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="stat.html" />
    
    
    <link rel="prev" href="share.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    入门
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../introduction/environment.html">
            
                <a href="../introduction/environment.html">
            
                    
                    环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../introduction/hello.html">
            
                <a href="../introduction/hello.html">
            
                    
                    HelloWorld
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../introduction/dev-and-debug.html">
            
                <a href="../introduction/dev-and-debug.html">
            
                    
                    开发与调试
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    参考
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../framework/file.html">
            
                <a href="../framework/file.html">
            
                    
                    文件组织
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../framework/manifest.html">
            
                <a href="../framework/manifest.html">
            
                    
                    manifest文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../framework/nml.html">
            
                <a href="../framework/nml.html">
            
                    
                    nml文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../framework/page.html">
            
                <a href="../framework/page.html">
            
                    
                    页面与组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    组件
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../component/general.html">
            
                <a href="../component/general.html">
            
                    
                    通用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../component/container.html">
            
                <a href="../component/container.html">
            
                    
                    容器组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../component/basics.html">
            
                <a href="../component/basics.html">
            
                    
                    基础组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../component/form.html">
            
                <a href="../component/form.html">
            
                    
                    表单组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../component/media.html">
            
                <a href="../component/media.html">
            
                    
                    媒体组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    接口
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="general.html">
            
                <a href="general.html">
            
                    
                    通用规则
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="basic.html">
            
                <a href="basic.html">
            
                    
                    基本功能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="interface.html">
            
                <a href="interface.html">
            
                    
                    界面交互
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="request.html">
            
                <a href="request.html">
            
                    
                    网络访问
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="storage.html">
            
                <a href="storage.html">
            
                    
                    文件数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="system.html">
            
                <a href="system.html">
            
                    
                    系统能力
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="media.html">
            
                <a href="media.html">
            
                    
                    图形图像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="share.html">
            
                <a href="share.html">
            
                    
                    分享
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5.9" data-path="pay.html">
            
                <a href="pay.html">
            
                    
                    支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="stat.html">
            
                <a href="stat.html">
            
                    
                    统计
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >支付</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x652F;&#x4ED8;">&#x652F;&#x4ED8;</h3>
<h4 id="&#x63A5;&#x53E3;&#x58F0;&#x660E;">&#x63A5;&#x53E3;&#x58F0;&#x660E;</h4>
<p>{&quot;name&quot;: &quot;service.pay&quot;}</p>
<h4 id="unipaygetproviderobject">uni.pay.getProvider(OBJECT)</h4>
<p>&#x83B7;&#x53D6;&#x670D;&#x52A1;&#x63D0;&#x4F9B;&#x5546;&#xFF0C;&#x5982;&#x5382;&#x5546;&#x7684;&#x82F1;&#x6587;&#x54C1;&#x724C;&#x540D;&#x79F0;&#xFF0C;&#x5047;&#x5982;&#x65E0;&#x6B64;&#x670D;&#x52A1;&#x5219;&#x8FD4;&#x56DE;&#x7A7A;&#x5B57;&#x7B26;&#x4E32;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<p>&#x65E0;&#x3002;</p>
<p>&#x8FD4;&#x56DE;&#x503C;</p>
<p>&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x670D;&#x52A1;&#x63D0;&#x4F9B;&#x5546;&#x7684;&#x4EE3;&#x53F7;&#x3002;</p>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.pay.getProvider();
</code></pre>
<h4 id="unipaypayobject">uni.pay.pay(OBJECT)</h4>
<p>&#x4F7F;&#x7528;&#x652F;&#x4ED8;&#x5B8C;&#x6210;&#x4ED8;&#x6B3E;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">orderInfo</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x8BA2;&#x5355;&#x4FE1;&#x606F;</td>
</tr>
<tr>
<td style="text-align:left">success</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6210;&#x529F;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">fail</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5931;&#x8D25;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">complete</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6267;&#x884C;&#x7ED3;&#x675F;&#x540E;&#x7684;&#x56DE;&#x8C03;</td>
</tr>
</tbody>
</table>
<p>success &#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">result</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x652F;&#x4ED8;&#x7ED3;&#x679C;</td>
</tr>
</tbody>
</table>
<p>fail &#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">code</td>
<td style="text-align:left">Number</td>
<td style="text-align:left">&#x8FD4;&#x56DE;&#x72B6;&#x6001;&#x7801;</td>
</tr>
<tr>
<td style="text-align:left">message</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x6D88;&#x606F;&#x5185;&#x5BB9;</td>
</tr>
</tbody>
</table>
<p>fail&#x5F02;&#x5E38;&#x7801;&#x8FD4;&#x56DE;&#xFF0C;&#x4E0D;&#x540C;&#x7684;&#x5382;&#x5546;&#x63D0;&#x4F9B;&#x7684;&#x5F02;&#x5E38;&#x7801;&#x4F1A;&#x6709;&#x5DEE;&#x5F02;&#xFF0C;&#x5177;&#x4F53;&#x7684;&#x5F02;&#x5E38;&#x7801;&#x9700;&#x8981;&#x548C;&#x5382;&#x5546;&#x652F;&#x4ED8;&#x63A5;&#x53E3;&#x5BF9;&#x63A5;&#x3002;</p>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.pay.pay({
  orderInfo: <span class="hljs-string">&quot;order1&quot;</span>,
  success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling success: &quot;</span> + data.code);
  },
  fail: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data, code</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling fail, code=&quot;</span> + code);
  }
});
</code></pre>
<h3 id="&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;">&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;</h3>
<h4 id="&#x63A5;&#x53E3;&#x58F0;&#x660E;">&#x63A5;&#x53E3;&#x58F0;&#x660E;</h4>
<p>{&quot;name&quot;: &quot;service.wxpay&quot;}</p>
<h4 id="uniwxpaygettype">uni.wxpay.getType()</h4>
<p>&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x53EF;&#x7528;&#x7684;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x8C03;&#x7528;&#x65B9;&#x5F0F;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<p>&#x65E0;&#x3002;</p>
<p>&#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x8FD4;&#x56DE;&#x503C;</th>
<th style="text-align:left">&#x5907;&#x6CE8;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">none</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;&#x672A;&#x5B89;&#x88C5;</td>
</tr>
<tr>
<td style="text-align:left">APP</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;app&#x8C03;&#x7528;&#x65B9;&#x5F0F;&#xFF0C;&#x670D;&#x52A1;&#x7AEF;&#x5411;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x4E0B;&#x5355;&#x65F6;&#xFF0C;trade_type&#x9700;&#x8981;&#x662F;APP&#xFF0C;&#x53C2;&#x8003;&quot;&#x5FAE;&#x4FE1;app&#x652F;&#x4ED8;&quot;&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">MWEB</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;&#x7F51;&#x9875;&#x8C03;&#x7528;&#x65B9;&#x5F0F;&#xFF0C;&#x670D;&#x52A1;&#x7AEF;&#x5411;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x4E0B;&#x5355;&#x65F6;&#xFF0C;trade_type&#x9700;&#x8981;&#x662F;MWEB&#xFF0C;&#x53C2;&#x8003;&quot;&#x5FAE;&#x4FE1;&#x7F51;&#x9875;&#x652F;&#x4ED8;&quot;&#x3002;</td>
</tr>
</tbody>
</table>
<h4 id="uniwxpaypayobject">uni.wxpay.pay(OBJECT)</h4>
<p>&#x53D1;&#x8D77;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">prepayid</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x670D;&#x52A1;&#x5668;&#x751F;&#x6210;&#x7684;&#x9884;&#x652F;&#x4ED8;&#x8BA2;&#x5355;id&#xFF0C;&#x53C2;&#x8003;&quot;&#x5FAE;&#x4FE1;app&#x652F;&#x4ED8;&quot;&#x548C;&quot;&#x5FAE;&#x4FE1;&#x7F51;&#x9875;&#x652F;&#x4ED8;&quot;&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">extra</td>
<td style="text-align:left">Object</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x5F53;&#x524D;&#x652F;&#x4ED8;&#x65B9;&#x5F0F;&#x4E0B;&#xFF0C;&#x9700;&#x8981;&#x586B;&#x5165;&#x7684;&#x989D;&#x5916;&#x8BA2;&#x5355;&#x4FE1;&#x606F;&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">success</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x6210;&#x529F;&#x540E;&#x7684;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x3002;App&#x65B9;&#x5F0F;&#x4E0B;&#xFF0C;&#x56DE;&#x8C03;&#x53D1;&#x751F;&#x5728;&#x7528;&#x6237;&#x652F;&#x4ED8;&#x5B8C;&#x6210;&#x4E4B;&#x540E;&#x3002;&#x7F51;&#x9875;&#x65B9;&#x5F0F;&#x4E0B;&#xFF0C;&#x56DE;&#x8C03;&#x53D1;&#x751F;&#x5728;&#x8BA2;&#x5355;&#x63D0;&#x4EA4;&#x7ED9;&#x5FAE;&#x4FE1;app&#x4E4B;&#x540E;&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">fail</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5931;&#x8D25;&#x56DE;&#x8C03;</td>
</tr>
<tr>
<td style="text-align:left">cancel</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x53D6;&#x6D88;&#x56DE;&#x8C03;</td>
</tr>
</tbody>
</table>
<p>extra&#x53C2;&#x6570;app&#x65B9;&#x5F0F;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x5B57;&#x6BB5;&#x540D;</th>
<th style="text-align:left">&#x5FC5;&#x9009;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">app_id</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x8BA2;&#x5355;&#x4E2D;&#x7684;app_id&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">partner_id</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x8BA2;&#x5355;&#x4E2D;&#x7684;partner_id&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">package_value</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x8BA2;&#x5355;&#x4E2D;&#x7684;package_value&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">nonce_str</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x8BA2;&#x5355;&#x4E2D;&#x7684;nonce_str&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">time_stamp</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x8BA2;&#x5355;&#x4E2D;&#x7684;time_stamp&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">order_sign</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x8BA2;&#x5355;&#x4E2D;&#x7684;order_sign&#x3002;</td>
</tr>
</tbody>
</table>
<p>extra&#x53C2;&#x6570;&#x7F51;&#x9875;&#x65B9;&#x5F0F;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x5B57;&#x6BB5;&#x540D;</th>
<th style="text-align:left">&#x5FC5;&#x9009;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">mweb_url</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5728;&#x5FAE;&#x4FE1;&#x7684;&#x652F;&#x4ED8;&#x670D;&#x52A1;&#x5668;&#x4E0B;&#x5355;&#x4EE5;&#x540E;&#xFF0C;&#x5FAE;&#x4FE1;&#x8FD4;&#x56DE;&#x7684;MWEB_URL&#xFF0C;&#x5728;CP&#x7528;&#x4E8E;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x7684;h5&#x9875;&#x9762;&#x4E2D;&#xFF0C;&#x76F4;&#x63A5;&#x5C06;mweb_url&#x53D6;&#x51FA;&#x540E;&#x8DF3;&#x8F6C;&#x8FC7;&#x53BB;&#x5373;&#x53EF;&#xFF0C;&#x4F46;&#x8FD9;&#x4E2A;&#x505A;&#x6CD5;&#x5E76;&#x4E0D;&#x662F;&#x5F3A;&#x5236;&#x7684;&#xFF0C;&#x60A8;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5176;&#x4ED6;&#x81EA;&#x5B9A;&#x4E49;&#x952E;&#x503C;&#x5411;&#x60A8;&#x81EA;&#x5DF1;&#x7684;&#x670D;&#x52A1;&#x5668;&#x6362;&#x53D6;MWEB_URL&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">custome_key</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x5176;&#x4ED6;&#x7684;&#x81EA;&#x5B9A;&#x4E49;&#x952E;&#x503C;&#xFF0C;cp&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x9700;&#x8981;&#x589E;&#x52A0;&#x5176;&#x4ED6;&#x81EA;&#x5DF1;&#x8BA4;&#x4E3A;&#x9700;&#x8981;&#x7684;&#x952E;&#x540D;&#x548C;&#x952E;&#x503C;&#x3002;</td>
</tr>
</tbody>
</table>
<p>success &#x8FD4;&#x56DE;&#x503C;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">prepayid</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x53EA;&#x5728;App&#x652F;&#x4ED8;&#x65B9;&#x5F0F;&#x4E0B;&#x4F1A;&#x51FA;&#x73B0;&#xFF0C;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x8BA2;&#x5355;&#x7684;prepayId&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">final_url</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x53EA;&#x5728;&#x7F51;&#x9875;&#x65B9;&#x5F0F;&#x4E0B;&#x4F1A;&#x51FA;&#x73B0;&#xFF0C;&#x62FC;&#x63A5;&#x53C2;&#x6570;&#x4E4B;&#x540E;&#xFF0C;&#x6700;&#x7EC8;&#x7528;&#x4E8E;&#x6253;&#x5F00;&#x7F51;&#x9875;&#x7684;url&#x3002;</td>
</tr>
</tbody>
</table>
<p>fail &#x8FD4;&#x56DE;&#x9519;&#x8BEF;&#x7801;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x9519;&#x8BEF;&#x7801;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">900</td>
<td style="text-align:left">&#x5728;manifest.json&#x4E2D;&#x914D;&#x7F6E;&#x7684;&#x5E94;&#x7528;&#x7B7E;&#x540D;&#x6709;&#x8BEF;&#xFF0C;&#x65E0;&#x6CD5;&#x89E3;&#x6790;</td>
</tr>
<tr>
<td style="text-align:left">901</td>
<td style="text-align:left">&#x5728;manifest.json&#x4E2D;&#x914D;&#x7F6E;&#x7684;&#x5E94;&#x7528;&#x5305;&#x540D;&#x6709;&#x8BEF;</td>
</tr>
<tr>
<td style="text-align:left">1000</td>
<td style="text-align:left">&#x5FAE;&#x4FE1;&#x672A;&#x5B89;&#x88C5;</td>
</tr>
<tr>
<td style="text-align:left">1001</td>
<td style="text-align:left">&#x7528;&#x4E8E;&#x5FAE;&#x4FE1;&#x7F51;&#x9875;&#x652F;&#x4ED8;&#x7684;url&#x914D;&#x7F6E;&#x627E;&#x4E0D;&#x5230;</td>
</tr>
<tr>
<td style="text-align:left">2001</td>
<td style="text-align:left">&#x8BA2;&#x5355;&#x5DF2;&#x7ECF;&#x63D0;&#x4EA4;&#x7ED9;&#x5FAE;&#x4FE1;&#xFF0C;&#x4F46;&#x662F;&#x5FAE;&#x4FE1;&#x8FD4;&#x56DE;&#x9519;&#x8BEF;, &#x53EF;&#x80FD;&#x7684;&#x539F;&#x56E0;&#xFF1A;&#x7B7E;&#x540D;&#x9519;&#x8BEF;&#x3001;&#x672A;&#x6CE8;&#x518C;APPID&#x3001;&#x9879;&#x76EE;&#x8BBE;&#x7F6E;APPID&#x4E0D;&#x6B63;&#x786E;&#x3001;&#x6CE8;&#x518C;&#x7684;APPID&#x4E0E;&#x8BBE;&#x7F6E;&#x7684;&#x4E0D;&#x5339;&#x914D;&#x3001;&#x5176;&#x4ED6;&#x5F02;&#x5E38;&#x7B49;&#x3002;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">useWxpay: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">var</span> payType = uni.wxpay.getType();
  <span class="hljs-keyword">if</span>(payType == <span class="hljs-string">&apos;APP&apos;</span>) {
    uni.wxpay.pay({
      <span class="hljs-comment">//&#x5FAE;&#x4FE1; app&#x652F;&#x4ED8;&#x7684;prepayId </span>
      prepayid: <span class="hljs-string">&apos;your order prepayid,eg: wx20170101abcdef1234567890&apos;</span>,
      extra: {
        app_id: <span class="hljs-string">&apos;your app_id&apos;</span>,
        partner_id: <span class="hljs-string">&apos;your partner_id&apos;</span>,
        package_value: <span class="hljs-string">&apos;your package_value&apos;</span>,
        nonce_str: <span class="hljs-string">&apos;your nonce_str&apos;</span>,
        time_stamp: <span class="hljs-string">&apos;your time_stamp&apos;</span>,
        order_sign: <span class="hljs-string">&apos;your order sign&apos;</span>
      },
      fail: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data, code</span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;WX PAY failed, code=&quot;</span> + code);
      },
      cancel: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;WX PAY cancelled by user&quot;</span>);
      },
      success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;WX PAY success&quot;</span>);
      }
    });
  } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(payType == <span class="hljs-string">&apos;MWEB&apos;</span>) {
    uni.wxpay.pay({
      <span class="hljs-comment">//&#x5FAE;&#x4FE1;&#x7F51;&#x9875;&#x652F;&#x4ED8;&#x7684;prepayId </span>
      prepayid: <span class="hljs-string">&apos;your order prepayid,eg: wx20170101abcdef1234567890&apos;</span>,
      extra: {
        <span class="hljs-comment">//&#x4F20;&#x9012;&#x7ED9;&#x652F;&#x4ED8;&#x9875;&#x9762;&#x7684;&#x81EA;&#x5B9A;&#x4E49;&#x53C2;&#x6570;, &#x6839;&#x636E;&#x9700;&#x8981;&#x8FDB;&#x884C;&#x8BBE;&#x7F6E;,&#x4F1A;&#x88AB;urlEncode&#x4E4B;&#x540E;&#x62FC;&#x63A5;&#x5728;&#x914D;&#x7F6E;&#x7684;url&#x5C3E;&#x90E8; </span>
        mweb_url: <span class="hljs-string">&apos;https://wx.tenpay.com/cgi-bin/mmpayweb-bin&apos;</span>,
        customeKey1: <span class="hljs-string">&apos;customeValue1&apos;</span>,
        customeKey2: <span class="hljs-string">&apos;customeValue2&apos;</span>
      },
      fail: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data, code</span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;WX H5 PAY handling fail, code=&quot;</span> + code);
      },
      cancel: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;WX H5 PAY handling cancel&quot;</span>);
      },
      success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
        <span class="hljs-comment">//H5&#x65B9;&#x5F0F;&#x4E0B;&#xFF0C;&#x652F;&#x4ED8;&#x6210;&#x529F;&#x7684;&#x56DE;&#x8C03;&#x4EC5;&#x4EC5;&#x53EA;&#x662F;&#x6307;&#x5C06;&#x8BA2;&#x5355;&#x9012;&#x4EA4;&#x7ED9;&#x5FAE;&#x4FE1;&#xFF0C;&#x5E76;&#x4E0D;&#x610F;&#x5473;&#x7740;&#x652F;&#x4ED8;&#x5DF2;&#x7ECF;&#x6210;&#x529F;&#x5B8C;&#x6210; </span>
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;WX H5 PAY handling success&quot;</span>);
      }
    });
  } <span class="hljs-keyword">else</span> {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;wx pay not avaliable.&quot;</span>);
  }
}
</code></pre>
<h4 id="&#x63A5;&#x5165;&#x8BF4;&#x660E;">&#x63A5;&#x5165;&#x8BF4;&#x660E;</h4>
<p>&#x65B9;&#x5F0F;&#x9009;&#x62E9;</p>
<p>app&#x652F;&#x4ED8;&#x53EA;&#x5728;&#x90E8;&#x5206;&#x624B;&#x673A;&#x7CFB;&#x7EDF;&#x4E0A;&#x88AB;&#x652F;&#x6301;&#xFF0C;&#x800C;&#x7F51;&#x9875;&#x652F;&#x4ED8;&#x5728;&#x6240;&#x6709;&#x624B;&#x673A;&#x7CFB;&#x7EDF;&#x4E0A;&#x5747;&#x80FD;&#x88AB;&#x652F;&#x6301;&#xFF0C;&#x4F46;&#x662F;&#x7F51;&#x9875;&#x652F;&#x4ED8;&#x4EA7;&#x751F;&#x652F;&#x4ED8;&#x56DE;&#x8C03;&#x7684;&#x65F6;&#x673A;&#x53D1;&#x751F;&#x5728;&#x8BA2;&#x5355;&#x63D0;&#x4EA4;&#x7ED9;&#x5FAE;&#x4FE1;&#x4E4B;&#x540E;&#xFF0C;&#x5E76;&#x975E;&#x548C;app&#x652F;&#x4ED8;&#x90A3;&#x6837;&#x53D1;&#x751F;&#x5728;&#x652F;&#x4ED8;&#x4EA7;&#x751F;&#x7ED3;&#x679C;&#x7684;&#x65F6;&#x5019;&#x3002;&#x63A8;&#x8350;cp&#x540C;&#x65F6;&#x652F;&#x6301;&#x4E24;&#x79CD;&#x63A5;&#x5165;&#x652F;&#x4ED8;&#x65B9;&#x5F0F;&#x3002;</p>
<p>app&#x652F;&#x4ED8;&#x63A5;&#x5165;</p>
<ol>
<li>&#x53C2;&#x8003;&quot;&#x5FAE;&#x4FE1;app&#x652F;&#x4ED8;&quot;&#xFF0C;&#x5B8C;&#x6210;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x670D;&#x52A1;&#x7AEF;&#x7684;&#x63A5;&#x5165;&#x3002;</li>
<li>&#x5728;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x540E;&#x53F0;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x65B0;&#x7684;app&#xFF0C;&#x8BE5;app&#x9700;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x5305;&#x540D;&#xFF0C;&#x4E0D;&#x8981;&#x548C;&#x81EA;&#x5DF1;android app&#x5E94;&#x7528;&#x7684;&#x5305;&#x540D;&#x51B2;&#x7A81;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x5BF9;&#x5916;&#x53D1;&#x5E03;&#xFF0C;&#x4F46;&#x662F;&#x9700;&#x8981;&#x63D0;&#x4EA4;&#x4E00;&#x4E2A;apk&#x4EE5;&#x6CE8;&#x518C;&#x65B0;&#x7684;&#x5305;&#x540D;&#x5BF9;&#x5E94;&#x7684;app&#x7B7E;&#x540D;&#x3002;</li>
<li>&#x5C06;&#x65B0;&#x6CE8;&#x518C;&#x7684;app&#x5305;&#x540D;&#x548C;app&#x7B7E;&#x540D;&#xFF08;&#x7B7E;&#x540D;&#x7684;&#x503C;&#x53EF;&#x4EE5;&#x5728;&#x5B89;&#x88C5;&#x65B0;&#x6CE8;&#x518C;&#x7684;apk&#x540E;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x5DE5;&#x5177;&#x83B7;&#x53D6;&#xFF09;&#x7684;&#x503C;&#xFF0C;&#x5206;&#x522B;&#x586B;&#x5728;manifest.json&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x63A5;&#x53E3;&#x58F0;&#x660E;&#x7684;package&#x548C;sign&#x4E24;&#x4E2A;&#x5B57;&#x6BB5;&#x4E2D;&#xFF0C;&#x5982;&#x63A5;&#x53E3;&#x58F0;&#x660E;&#x4E2D;&#x6240;&#x793A;&#x3002;</li>
</ol>
<p>&#x7F51;&#x9875;&#x652F;&#x4ED8;&#x63A5;&#x5165;</p>
<ol>
<li>&#x53C2;&#x8003;&quot;&#x5FAE;&#x4FE1;&#x7F51;&#x9875;&#x652F;&#x4ED8;&quot;&#xFF0C;&#x5B8C;&#x6210;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x670D;&#x52A1;&#x7AEF;&#x7684;&#x63A5;&#x5165;&#x3002;</li>
<li>&#x5728;&#x670D;&#x52A1;&#x7AEF;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x53D1;&#x8D77;&#x652F;&#x4ED8;&#x7684;H5&#x9875;&#x9762;&#xFF0C;&#x8BE5;&#x9875;&#x9762;&#x8BFB;&#x53D6;&#x4F20;&#x5165;&#x7684;mweb_url&#xFF0C;&#x7136;&#x540E;&#x81EA;&#x52A8;&#x8DF3;&#x8F6C;&#x5230;mweb_url&#x3002;&#x5C06;&#x6B65;&#x9AA4;2&#x4E2D;&#x652F;&#x4ED8;H5&#x9875;&#x9762;&#x5BF9;&#x5E94;&#x7684;url&#x586B;&#x5728;manifest.json&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x63A5;&#x53E3;&#x58F0;&#x660E;&#x7684;url&#x5B57;&#x6BB5;&#x4E2D;&#xFF0C;&#x5982;&#x63A5;&#x53E3;&#x58F0;&#x660E;&#x4E2D;&#x6240;&#x793A;&#x3002;</li>
</ol>
<h3 id="&#x652F;&#x4ED8;&#x5B9D;&#x652F;&#x4ED8;">&#x652F;&#x4ED8;&#x5B9D;&#x652F;&#x4ED8;</h3>
<h4 id="&#x63A5;&#x53E3;&#x58F0;&#x660E;">&#x63A5;&#x53E3;&#x58F0;&#x660E;</h4>
<p>{&quot;name&quot;: &quot;service.alipay&quot;}</p>
<h4 id="unialipaypayobject">uni.alipay.pay(OBJECT)</h4>
<p>&#x4F7F;&#x7528;&#x652F;&#x4ED8;&#x5B9D;&#x652F;&#x5B8C;&#x6210;&#x652F;&#x4ED8;&#x3002;</p>
<p>&#x53C2;&#x6570;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">orderInfo</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x670D;&#x52A1;&#x7AEF;&#x751F;&#x6210;&#x7684;&#x8BA2;&#x5355;&#x4FE1;&#x606F;&#xFF0C;&#x53C2;&#x8003;&#x652F;&#x4ED8;&#x5B9D;&#x7684;&quot;&#x8BF7;&#x6C42;&#x53C2;&#x6570;&#x8BF4;&#x660E;&#x6587;&#x6863;&quot;&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">callback</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5426;</td>
<td style="text-align:left">&#x652F;&#x4ED8;&#x7ED3;&#x679C;&#x56DE;&#x8C03;&#xFF0C;&#x683C;&#x5F0F;&#x53C2;&#x8003;&#x652F;&#x4ED8;&#x5B9D;&#x7684;&quot;&#x901A;&#x77E5;&#x53C2;&#x6570;&#x8BF4;&#x660E;&#x6587;&#x6863;&quot;&#x3002;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-javascript">uni.alipay.pay({
  orderInfo: <span class="hljs-string">&quot;order1&quot;</span>,
  callback: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">ret</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;handling callback&quot;</span>);
  }
});
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="share.html" class="navigation navigation-prev " aria-label="Previous page: 分享">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="stat.html" class="navigation navigation-next " aria-label="Next page: 统计">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"支付","level":"1.5.9","depth":2,"next":{"title":"统计","level":"1.5.10","depth":2,"path":"api/stat.md","ref":"api/stat.md","articles":[]},"previous":{"title":"分享","level":"1.5.8","depth":2,"path":"api/share.md","ref":"api/share.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"api/pay.md","mtime":"2018-04-04T08:13:29.042Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-04-04T08:24:24.953Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

